/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package slicktest.util;

import slicktest.data.StatMod;
import slicktest.types.MathEffectType;

/**
 * utility class for doing stat mod calculation, the idea being that
 * you hand this class a StatMod and the stat it modifies, 
 * and it'll give you back a double.
 * @author enrightt
 */
public class StatModUtil {

    //takes a stat passed in as a double and returns the new value with the
    //presented stat modifier taken into account.
    public static double aggregateDoubleStat(double stat, StatMod mod) {
        double result = stat;

        MathEffectType modType = mod.type;

        if(modType.equals(MathEffectType.ADDITIVE)) {
            result += mod.modifier;
        } else if(modType.equals(MathEffectType.MULTIPLICATIVE)) {
            result += result * mod.modifier;
        }

        return result;
    }
}
